package com.rftennis.vo;

import java.time.format.DateTimeFormatter;

import com.rftennis.entity.CustomerEntity;
import com.rftennis.entity.OrderEntity;

import lombok.Data;
@Data
public class OrderVo {
	private String id;//订单编号
	private String ordNo;//订单号
	private String phoneNumber;//手机号
	private String name;//订单收货人名字
	private String address;//顾客的收货地址
	private String status;//订单状态
	private String price;//订单总价
	//private String customerName;//订单所属顾客姓名
	private String customerId;//订单所属顾客的id
	private String createTime;//创建时间
	public static OrderVo of(OrderEntity e) {
		OrderVo vo=new OrderVo();
		vo.setAddress(e.getAddress());
		DateTimeFormatter df =DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
		vo.setCreateTime(df.format(e.getCreateTime()));
		//vo.setCustomerName(e.getCustomer().getName());
		vo.setCustomerId(e.getCustomerId());
		vo.setId(e.getId());
		vo.setName(e.getName());
		vo.setPhoneNumber(e.getPhoneNumber());
		vo.setPrice(e.getPrice());
		 int a = Integer.parseInt(e.getStatus());
		 String status;
		if(a==1) {
			status="待收货";
		}else {
			status="已收货";
		}
		vo.setStatus(status);
		vo.setOrdNo(e.getOrdNo());
		
		return vo;
	}
	@Override
	public String toString() {
		return "OrderVo [id=" + id + ", ordNo=" + ordNo + ", phoneNumber=" + phoneNumber + ", name=" + name
				+ ", address=" + address + ", status=" + status + ", price=" + price + ", customerId=" + customerId
				+ ", createTime=" + createTime + "]";
	}
	
	
}
